Add some docs for GTK_NEED_REQUEST GTK_NEED_ALLOCATION.
authorOwen Taylor <otaylor@redhat.com>
Mon, 18 Feb 2002 22:08:41 +0000 (22:08 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Mon, 18 Feb 2002 22:08:41 +0000 (22:08 +0000)
Mon Feb 18 16:44:00 2002  Owen Taylor  <otaylor@redhat.com>

        * docs/widget_system.txt: Add some docs for GTK_NEED_REQUEST
        GTK_NEED_ALLOCATION.

        * gtk/gtkmenu.c (gtk_menu_popup): Scroll the menu
        to the right place before showing the menu to
        avoid spurious enter events.

        * gtk/gtkmenu.c (gtk_menu_realize): Only scroll
        if there is an active menu item.

        * gtk/gtkwidget.c (gtk_widget_init): Set RESIZE_NEEDED
        ALLOC_NEEDED initially.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/widget_system.txt
gtk/gtkmenu.c
gtk/gtkwidget.c

index 1f52dd6ae4bce1aac4f9a6c1fd61def5bf585a3f..7ee3165be9ab5c1478eef07b2b0c02d0058c3497 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Mon Feb 18 16:44:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/widget_system.txt: Add some docs for GTK_NEED_REQUEST
+       GTK_NEED_ALLOCATION.
+
+       * gtk/gtkmenu.c (gtk_menu_popup): Scroll the menu
+       to the right place before showing the menu to
+       avoid spurious enter events.
+
+       * gtk/gtkmenu.c (gtk_menu_realize): Only scroll
+       if there is an active menu item.
+
+       * gtk/gtkwidget.c (gtk_widget_init): Set RESIZE_NEEDED
+       ALLOC_NEEDED initially.
+
 2002-02-18  Matthias Clasen  <maclas@gmx.de>
 
        * NEWS: fix version number.
@@ -12,8 +27,8 @@ Mon Feb 18 14:40:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c (gtk_combo_popdown_list): Fix problems
        with stuck grab (#60132, reported by Nicolas Setton) and
-       stuck prelighting combine some common code for button release
-       and pressing Escape.
+       stuck prelighting. Combine duplicated code in three
+       places for popping down the list.
 
 Mon Feb 18 14:17:59 2002  Owen Taylor  <otaylor@redhat.com>
 
index 1f52dd6ae4bce1aac4f9a6c1fd61def5bf585a3f..7ee3165be9ab5c1478eef07b2b0c02d0058c3497 100644 (file)
@@ -1,3 +1,18 @@
+Mon Feb 18 16:44:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/widget_system.txt: Add some docs for GTK_NEED_REQUEST
+       GTK_NEED_ALLOCATION.
+
+       * gtk/gtkmenu.c (gtk_menu_popup): Scroll the menu
+       to the right place before showing the menu to
+       avoid spurious enter events.
+
+       * gtk/gtkmenu.c (gtk_menu_realize): Only scroll
+       if there is an active menu item.
+
+       * gtk/gtkwidget.c (gtk_widget_init): Set RESIZE_NEEDED
+       ALLOC_NEEDED initially.
+
 2002-02-18  Matthias Clasen  <maclas@gmx.de>
 
        * NEWS: fix version number.
@@ -12,8 +27,8 @@ Mon Feb 18 14:40:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c (gtk_combo_popdown_list): Fix problems
        with stuck grab (#60132, reported by Nicolas Setton) and
-       stuck prelighting combine some common code for button release
-       and pressing Escape.
+       stuck prelighting. Combine duplicated code in three
+       places for popping down the list.
 
 Mon Feb 18 14:17:59 2002  Owen Taylor  <otaylor@redhat.com>
 
index 1f52dd6ae4bce1aac4f9a6c1fd61def5bf585a3f..7ee3165be9ab5c1478eef07b2b0c02d0058c3497 100644 (file)
@@ -1,3 +1,18 @@
+Mon Feb 18 16:44:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/widget_system.txt: Add some docs for GTK_NEED_REQUEST
+       GTK_NEED_ALLOCATION.
+
+       * gtk/gtkmenu.c (gtk_menu_popup): Scroll the menu
+       to the right place before showing the menu to
+       avoid spurious enter events.
+
+       * gtk/gtkmenu.c (gtk_menu_realize): Only scroll
+       if there is an active menu item.
+
+       * gtk/gtkwidget.c (gtk_widget_init): Set RESIZE_NEEDED
+       ALLOC_NEEDED initially.
+
 2002-02-18  Matthias Clasen  <maclas@gmx.de>
 
        * NEWS: fix version number.
@@ -12,8 +27,8 @@ Mon Feb 18 14:40:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c (gtk_combo_popdown_list): Fix problems
        with stuck grab (#60132, reported by Nicolas Setton) and
-       stuck prelighting combine some common code for button release
-       and pressing Escape.
+       stuck prelighting. Combine duplicated code in three
+       places for popping down the list.
 
 Mon Feb 18 14:17:59 2002  Owen Taylor  <otaylor@redhat.com>
 
index 1f52dd6ae4bce1aac4f9a6c1fd61def5bf585a3f..7ee3165be9ab5c1478eef07b2b0c02d0058c3497 100644 (file)
@@ -1,3 +1,18 @@
+Mon Feb 18 16:44:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/widget_system.txt: Add some docs for GTK_NEED_REQUEST
+       GTK_NEED_ALLOCATION.
+
+       * gtk/gtkmenu.c (gtk_menu_popup): Scroll the menu
+       to the right place before showing the menu to
+       avoid spurious enter events.
+
+       * gtk/gtkmenu.c (gtk_menu_realize): Only scroll
+       if there is an active menu item.
+
+       * gtk/gtkwidget.c (gtk_widget_init): Set RESIZE_NEEDED
+       ALLOC_NEEDED initially.
+
 2002-02-18  Matthias Clasen  <maclas@gmx.de>
 
        * NEWS: fix version number.
@@ -12,8 +27,8 @@ Mon Feb 18 14:40:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c (gtk_combo_popdown_list): Fix problems
        with stuck grab (#60132, reported by Nicolas Setton) and
-       stuck prelighting combine some common code for button release
-       and pressing Escape.
+       stuck prelighting. Combine duplicated code in three
+       places for popping down the list.
 
 Mon Feb 18 14:17:59 2002  Owen Taylor  <otaylor@redhat.com>
 
index 1f52dd6ae4bce1aac4f9a6c1fd61def5bf585a3f..7ee3165be9ab5c1478eef07b2b0c02d0058c3497 100644 (file)
@@ -1,3 +1,18 @@
+Mon Feb 18 16:44:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/widget_system.txt: Add some docs for GTK_NEED_REQUEST
+       GTK_NEED_ALLOCATION.
+
+       * gtk/gtkmenu.c (gtk_menu_popup): Scroll the menu
+       to the right place before showing the menu to
+       avoid spurious enter events.
+
+       * gtk/gtkmenu.c (gtk_menu_realize): Only scroll
+       if there is an active menu item.
+
+       * gtk/gtkwidget.c (gtk_widget_init): Set RESIZE_NEEDED
+       ALLOC_NEEDED initially.
+
 2002-02-18  Matthias Clasen  <maclas@gmx.de>
 
        * NEWS: fix version number.
@@ -12,8 +27,8 @@ Mon Feb 18 14:40:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c (gtk_combo_popdown_list): Fix problems
        with stuck grab (#60132, reported by Nicolas Setton) and
-       stuck prelighting combine some common code for button release
-       and pressing Escape.
+       stuck prelighting. Combine duplicated code in three
+       places for popping down the list.
 
 Mon Feb 18 14:17:59 2002  Owen Taylor  <otaylor@redhat.com>
 
index 1f52dd6ae4bce1aac4f9a6c1fd61def5bf585a3f..7ee3165be9ab5c1478eef07b2b0c02d0058c3497 100644 (file)
@@ -1,3 +1,18 @@
+Mon Feb 18 16:44:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/widget_system.txt: Add some docs for GTK_NEED_REQUEST
+       GTK_NEED_ALLOCATION.
+
+       * gtk/gtkmenu.c (gtk_menu_popup): Scroll the menu
+       to the right place before showing the menu to
+       avoid spurious enter events.
+
+       * gtk/gtkmenu.c (gtk_menu_realize): Only scroll
+       if there is an active menu item.
+
+       * gtk/gtkwidget.c (gtk_widget_init): Set RESIZE_NEEDED
+       ALLOC_NEEDED initially.
+
 2002-02-18  Matthias Clasen  <maclas@gmx.de>
 
        * NEWS: fix version number.
@@ -12,8 +27,8 @@ Mon Feb 18 14:40:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c (gtk_combo_popdown_list): Fix problems
        with stuck grab (#60132, reported by Nicolas Setton) and
-       stuck prelighting combine some common code for button release
-       and pressing Escape.
+       stuck prelighting. Combine duplicated code in three
+       places for popping down the list.
 
 Mon Feb 18 14:17:59 2002  Owen Taylor  <otaylor@redhat.com>
 
index 1f52dd6ae4bce1aac4f9a6c1fd61def5bf585a3f..7ee3165be9ab5c1478eef07b2b0c02d0058c3497 100644 (file)
@@ -1,3 +1,18 @@
+Mon Feb 18 16:44:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/widget_system.txt: Add some docs for GTK_NEED_REQUEST
+       GTK_NEED_ALLOCATION.
+
+       * gtk/gtkmenu.c (gtk_menu_popup): Scroll the menu
+       to the right place before showing the menu to
+       avoid spurious enter events.
+
+       * gtk/gtkmenu.c (gtk_menu_realize): Only scroll
+       if there is an active menu item.
+
+       * gtk/gtkwidget.c (gtk_widget_init): Set RESIZE_NEEDED
+       ALLOC_NEEDED initially.
+
 2002-02-18  Matthias Clasen  <maclas@gmx.de>
 
        * NEWS: fix version number.
@@ -12,8 +27,8 @@ Mon Feb 18 14:40:22 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcombo.c (gtk_combo_popdown_list): Fix problems
        with stuck grab (#60132, reported by Nicolas Setton) and
-       stuck prelighting combine some common code for button release
-       and pressing Escape.
+       stuck prelighting. Combine duplicated code in three
+       places for popping down the list.
 
 Mon Feb 18 14:17:59 2002  Owen Taylor  <otaylor@redhat.com>
 
index 26efd02acde7f94baad0f2fabb6d2c552430d15c..eb7dce32d2522ce41f2cbeccf2b470b5e0ecb61e 100644 (file)
@@ -195,6 +195,20 @@ GTK_IN_REPARENT:
        to have this flag set to prevent natural unrealization on the
        process of getting unparented.
 
+GTK_NEED_REQUEST:
+       This flag is set if the widget doesn't have an up to date 
+       requisition. If this flag is set, we must actually emit ::size-request
+        when gtk_widget_size_request() is called. Otherwise, we can
+        simply widget->requisition. We keep track of this all the time
+        howevever, widgets with this flag set are only added to the resize 
+       queue if they are viewable.
+
+GTK_NEED_ALLOCATION:
+       This flag is set if the widget doesn't have an up to date 
+       allocation. If this flag is set, we must actually emit ::size-allocate
+        when gtk_widget_size_allocate() is called, even if the new allocation
+        is the same as the current allocation.
 Related Macros:
 
 GTK_WIDGET_DRAWABLE:
index 930f183644c65ba92d2be329841e7f2c785547f1..422e8d3b1fcbd19c2c175e61573b1b709e7680d5 100644 (file)
@@ -742,17 +742,38 @@ gtk_menu_popup (GtkMenu               *menu,
   menu->position_func_data = data;
   menu_shell->activate_time = activate_time;
 
-  gtk_menu_position (menu);
-
-  /* We need to show the menu _here_ because code expects to be
-   * able to tell if the menu is onscreen by looking at the
-   * GTK_WIDGET_VISIBLE (menu)
+  /* We need to show the menu here rather in the init function because
+   * code expects to be able to tell if the menu is onscreen by
+   * looking at the GTK_WIDGET_VISIBLE (menu)
    */
   gtk_widget_show (GTK_WIDGET (menu));
-  gtk_widget_show (menu->toplevel);
+
+  /* Compute the size of the toplevel and realize it so we
+   * can position and scroll correctly.
+   */
+  {
+    GtkRequisition tmp_request;
+    GtkAllocation tmp_allocation = { 0, };
+
+    gtk_widget_size_request (menu->toplevel, &tmp_request);
+    
+    tmp_allocation.width = tmp_request.width;
+    tmp_allocation.height = tmp_request.height;
+
+    gtk_widget_size_allocate (menu->toplevel, &tmp_allocation);
+    
+    gtk_widget_realize (GTK_WIDGET (menu));
+  }
+
+  gtk_menu_position (menu);
 
   gtk_menu_scroll_to (menu, menu->scroll_offset);
 
+  /* Once everything is set up correctly, map the toplevel window on
+     the screen.
+   */
+  gtk_widget_show (menu->toplevel);
+
   if (xgrab_shell == widget)
     popup_grab_on_window (widget->window, activate_time); /* Should always succeed */
 
@@ -1297,8 +1318,9 @@ gtk_menu_realize (GtkWidget *widget)
   gtk_style_set_background (widget->style, menu->view_window, GTK_STATE_NORMAL);
   gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
 
-  gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget),
-                               GTK_MENU_SHELL (widget)->active_menu_item);
+  if (GTK_MENU_SHELL (widget)->active_menu_item)
+    gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget),
+                                 GTK_MENU_SHELL (widget)->active_menu_item);
 
   gdk_window_show (menu->bin_window);
   gdk_window_show (menu->view_window);
index 625f12cf27b48241b4805e6ce064eb63889b368f..293cd6f625103e9765ba7e8f862011918089cc2a 100644 (file)
@@ -1283,6 +1283,8 @@ gtk_widget_init (GtkWidget *widget)
                        GTK_DOUBLE_BUFFERED);
 
   GTK_PRIVATE_SET_FLAG (widget, GTK_REDRAW_ON_ALLOC);
+  GTK_PRIVATE_SET_FLAG (widget, GTK_REQUEST_NEEDED);
+  GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED);
 
   widget->style = gtk_widget_get_default_style ();
   g_object_ref (widget->style);